#define _CRT_SECURE_NO_WARNINGS 1

#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 5;
int n, m, fa[MAX_N][21], dep[MAX_N], power[MAX_N], ans;
vector<int> E[MAX_N], P[MAX_N];


void dfs(int u, int f)
{
	dep[u] = dep[f] + 1;
	fa[u][0] = f;

	for (int i = 1; i <= 20; i++)
	{
		fa[u][i] = fa[fa[u][i - 1]][i - 1];
	}

	for (auto& v : E[u])
	{
		if (v == f) continue;
		dfs(v, u);
	}
}


int lca(int u, int v)
{
	if (dep[u] < dep[v]) swap(u, v);

	for (int i = 20; i >= 0; i--)
	{
		if (dep[fa[u][i]] >= dep[v])
			u = fa[u][i];
	}

	if (u == v) return u;

	for (int i = 20; i >= 0; i--)
	{
		if (fa[u][i] != fa[v][i])
			u = fa[u][i], v = fa[v][i];
	}

	return fa[u][0];
}

void dfs2(int u, int f)
{
	for (int i = 0; i < E[u].size(); i++)
	{
		int v = E[u][i], p = P[u][i];
		if (v == f) continue;
		dfs2(v, u);
		power[u] += power[v];

		if (power[v] == m) ans = max(ans, p);
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		E[a].push_back(b);
		P[a].push_back(i);
		E[b].push_back(a);
		P[b].push_back(i);
	}
	dfs(1, 0);

	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		int l = lca(a, b);
		power[a]++, power[b]++;
		power[l] -= 2;
	}
	dfs2(1, 0);

	cout << ans;
	return 0;
}


/*
6 2
1 2
2 3
4 3
2 5
6 5
3 6
4 5
*/

